using System.Collections.Generic;
using System.Web.Http.Description;
using System.Linq;
using Daemon.Data.Substructure.Framework;
using Daemon.Data.Infrastructure.FrameWork;
using System;
namespace DaemonAPI.Controllers
{
    public class RawSearchCondition
    {
        private List<string> _fields;

        /// <summary>
        /// Select only a subset of fields by providing a list of field names (Only works with search api)
        /// </summary>
        public List<string> Fields { get => _fields; set => _fields = value.Distinct().ToList(); }

        /// <summary>
        /// Filter Clause property
        /// </summary>
        [ApiExplorerSettings(IgnoreApi = true)]
        public string FilterClause { get; set; }

        /// <summary>
        /// Only get the dictinct data list.
        /// </summary>
        public bool IsDistinct { get; set; }

        /// <summary>
        /// Used to specify conditionals within specified fields
        /// </summary>
        public virtual FilterSet FilterSet { get; set; }

        /// <summary>
        /// Separate filter for including and excluding based on id
        /// </summary>
        public IdFilter IdFilter { get; set; }

        public bool? IsQuickSearch { get; set; }

        /// <summary>
        /// Used to specify what field to sort by and the order (ascending or descending)
        /// </summary>
        public List<SortItem> SortItems { get; set; }
    }

    /// <summary>
    /// The wrapping object of searching conditions
    /// </summary>
    public class SearchCondition<TGridEntity> : RawSearchCondition
        where TGridEntity : class
    {
        private FilterSet _filterSet;

        public override FilterSet FilterSet
        {
            get => _filterSet;
            set
            {
                _filterSet = value;
            }
        }
    }

    public class ReportSearchCondition : RawSearchCondition
    {
        public string Description { get; set; }

        public string Preparer { get; set; }

        public string RunFor { get; set; }

        public string SubTitle { get; set; }

        public DateTime? TimeFrom { get; set; }

        public DateTime? TimeTo { get; set; }

        public string Title { get; set; }
    }

    public class ReportSearchConditionWithEmail : ReportSearchCondition
    {
        public string EmailAddress { get; set; }

        public string EmailMessage { get; set; }

        public string EmailSubject { get; set; }

        public string FileName { get; set; }

        public List<string> MailToList { get; set; }
    }

    /// <summary>
    /// class for Id Filter entity
    /// </summary>
    public class IdFilter
    {
        /// <summary>
        /// ExcludeAny property
        /// </summary>
        public List<int> ExcludeAny { get; set; }

        /// <summary>
        /// IncludeOnly property
        /// </summary>
        public List<int> IncludeOnly { get; set; }
    }
}